package main

import (
	"fmt"
	"gorm-study/src/pkg/utils/dbutil"

	"gorm.io/gorm"
)

func main() {
	var age int64
	dbutil.DB.Raw("select age from students where name = ?", "张三").Scan(&age)
	fmt.Printf("修改前，张三的年龄：%v \n", age)

	result := dbutil.DB.Exec("update students set age = ? where name = ?", gorm.Expr("age + ?", 1), "张三")
	fmt.Printf("生效行数：%v \n", result.RowsAffected)

	dbutil.DB.Raw("select age from students where name = ?", "张三").Scan(&age)
	fmt.Printf("修改后，张三的年龄：%v \n", age)
}
